package com.lkd.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lkd.domain.Region;
import com.lkd.mapper.RegionMapper;
import com.lkd.pageParam.RegionPageParam;
import com.lkd.service.IRegionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lkd.vo.RegionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 运营区域 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-02-09
 */
@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements IRegionService {
    @Autowired
    private RegionMapper regionMapper;
    @Override
    public Page<RegionVo> getPage(RegionPageParam param) {
        Page<RegionVo> page = new Page<>();
        List<RegionVo> list =  regionMapper.getRegionVoList(param.getName());
        list.stream().forEach(s->s.setNodeCount(s.getNodeList().size()));
        page.setSize(param.getPageSize()).setRecords(list).setTotal(list.size()).setPages(param.getPageIndex());
        return page;
    }
}
